package ${package.Controller};


import com.xx.entity.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.MybatisPlusPager;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import com.xx.service.*;
import com.xx.other.*;
import javax.validation.constraints.NotEmpty;
import com.xx.Result;
import com.xx.bean.entity.PageRequest;
<#if restControllerStyle>
import org.springframework.web.bind.annotation.RestController;
<#else>
import org.springframework.stereotype.Controller;
</#if>
<#if superControllerClassPackage??>
import ${superControllerClassPackage};
</#if>

/**
 * <p>
 * ${table.comment!} 前端控制器
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
<#if restControllerStyle>
@RestController
<#else>
@Controller
</#if>
@RequestMapping("<#if package.ModuleName?? && package.ModuleName != "">/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}</#if>")
<#if kotlin>
class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if>
<#else>
<#if superControllerClass??>
public class ${table.controllerName} extends ${superControllerClass} {
<#else>
public class ${table.controllerName} {
</#if>

    /**
    * service
    */
    @Resource
    private ${table.serviceName} service;

    /**
    * 根据主键查询Vo
    *
    * @param pk 主键
    * @return Vo
    */
    @GetMapping("query")
    @ApiOperation(value = "根据主键查询Vo", notes = "根据主键查询Vo")
    @OperationLogAnnotation(moduleName = "根据主键查询Vo", functionName = "根据主键查询Vo")
    public Result<${entity}Vo> getByPk(@Validated @NotEmpty String pk) {
        return Result.success(this.service.getByPk(pk));
    }

    /**
    * 根据主键删除
    *
    * @param pk 主键
    * @return 删除结果
    */
    @DeleteMapping("/{pk}")
    @ApiOperation(value = "根据主键删除", notes = "根据主键删除")
    @OperationLogAnnotation(moduleName = "根据主键删除", functionName = "根据主键删除")
    @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "string")
    public Result<?> deleteByPk(@Validated @NotEmpty @PathVariable("pk") String pk) {
        return Result.success(this.service.deleteByPk(pk));
    }


    /**
    * 分页查询
    *
    * @return Result
    */
    @GetMapping("/page")
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @OperationLogAnnotation(moduleName = "分页查询", functionName = "分页查询")
    @Verify
    public Result<List<${entity}Vo>> page(${entity}Dto param) {
<#--        MybatisPlusPager<${entity}Vo> pager = MybatisPlusPager.createPager(param);-->
        MybatisPlusPager<${entity}Vo> page = this.service.selectPageByDto(MybatisPlusPager.createPager(param), param);
        return page.toResultPager();
    }
}
</#if>
